package com.scsj.cloud.authority;

import javax.servlet.MultipartConfigElement;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

/** 
 * @ClassName:         ShiroServerApplication 
 * @Description:       ShiroServerApplication 权限启动类
 * @author             caoxiubin
 * @date               2018年5月10日 下午2:29:12 
 */
@SpringBootApplication
@EnableDiscoveryClient
@ComponentScan(basePackages = { "com.scsj.cloud" })
@EntityScan(basePackages = "com.scsj.cloud.**.model")
@MapperScan(basePackages="com.scsj.cloud.**.dao")
public class AuthorityServerApplication {
	
	public static void main(String[] args) {
        
        ApplicationContext applicationContext = 
                SpringApplication.run(SpringBootApplication .class, args);
    }
	
	
	// 实例化ribbbon对象
	@Bean
	@LoadBalanced
	RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	
	/**
	 * 配置文件上传的临时目录，防止长时间不操作，系统删除默认目录
	 * @return
	 */
	@Bean
	MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		factory.setLocation("/app/tmp");
		return factory.createMultipartConfig();
	}
	

}
